package ldh.serialize.type;

import java.io.IOException;

import ldh.serialize.BinarySerialized;
import ldh.serialize.Serialized;
import ldh.serialize.io.ByteBuf;

public class PackSerialized<T> implements BinarySerialized<T> {
	
	private BinarySerialized<T> serialized;
	private Class<T> clazzType;
	
	public PackSerialized(Serialized<T> serialized, Class<T> clazzType) {
		this.serialized = (BinarySerialized<T>)serialized;
		this.clazzType = clazzType;
	}
	
	@Override
	public void write(ByteBuf out, T t) throws IOException {
		serialized.write(out, t);
	}

	@Override
	public T read(ByteBuf in) throws IOException {
		return serialized.read(in);
	}

	@Override
	public Class<T> getClassType() {
		return clazzType;
	}

}
